import { checkStr } from "@/utils/judge";
import store from "@/store";
import url from "@/axios/url";
const { mesUrl, adminUrl } = url();
import { deleteFile } from "@/api/common";
// const { mesUrl } = url();
let vm = null;
const sendThis = (_this) => {
  vm = _this;
};
export { sendThis };


// 驳回表单配置
export const formDescDialogMixin = {
  data() {
    const self = this;
    return {
      rejectFormDialog: {
        span: 24,
        disabled: false,
        inline: true,
        isShowSubmitBtn: false,
        isShowBackBtn: false,
        rules: {
          rejectReason: [
            { max: 300, message: $i18n.t("common.overlongPrompt", { length: 300 }), trigger: ["change", "blur"] }
          ],
        },
        formDesc: {
          rejectReason: {
            type: "textarea",
            label: "驳回原因",
            layout: 24,
            required: true,
            disabled: (d) => !!d.id,
          },
          rejectPictures: {
            type: "image-uploader",
            label: '驳回图片',
            layout: 24,
            required: false,
            attrs: {
              limit: 5,
              fileSize: 3, // 文件大小限制 单位M
              // fileType: ["png"],
              multiple: true, // 是否支持多选
              // disabled: true,
              size: 60, // 图片显示大小
              action: `${adminUrl}file`,
              data: {
                bucket: "messervice",
              },
              headers: {
                Satoken: store.getters.token,
              },
              beforeRemove: (data, list) => {
                const bucket = "messervice";
                const filename = data.title;
                console.log(filename)
                return new Promise((resolve, reject) => {
                  deleteFile(`${adminUrl}file`, {
                    bucket,
                    filename,
                  })
                    .then((res) => {
                      resolve(res.data);
                    })
                    .catch((error) => {
                      reject(error);
                    });
                });
              },
              responseFn(response, file) {
                return {
                  src: response.result.path,
                  // title: response.result.object,
                  ...response.result,
                };
              },
            },
          },
        },
      },
    };
  },
};

